////////////////////////// 校验输入内容的 方法
//是否有效的Email;
function isEMail(_str){
    var pattern = /^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$/;
    return pattern.test(_str);
}
//是否有效的数字;

function isNumber(_str){
    var pattern = /^[0-9]/;
    return pattern.test(_str);
}

//多选下拉菜单是否已选择至少一项;
function ListIsSelected(theSelect){
	for (var i = 0; i < theSelect.length; i++) {
		if (theSelect.options[i].selected == true) {
			return true;
		}
	}
	return false;
}



function checkForm(oForm)
{
    var els = oForm.elements;
    for(var i=0;i<els.length;i++)
    {
        if(els[i].check)
        {
            var sReg = els[i].check;
            var sVal = GetValue(els[i]);
            var reg = new RegExp(sReg,"i");

            if(!reg.test(sVal))
            {
                alert(els[i].warning);
                GoBack(els[i]);
                return false;
            }
        }
    }
}

function GetValue(el)
{
    var sType = el.type;
    switch(sType)
    {
        case "text":
        case "hidden":
        case "password":
        case "file":
        case "textarea": return el.value;
        case "checkbox":
        case "radio": return GetValueChoose(el);
        case "select-one":
        case "select-multiple": return GetValueSel(el);
    }
    function GetValueChoose(el)
    {
        var sValue = "";
        var tmpels = document.getElementsByName(el.name);
        for(var i=0;i<tmpels.length;i++)
        {
            if(tmpels[i].checked)
            {
                sValue += "0";
            }
        }
        return sValue;
    }
    function GetValueSel(el)
    {
        var sValue = "";
        for(var i=0;i<el.options.length;i++)
        {
            if(el.options[i].selected && el.options[i].value!="")
            {
                sValue += "0";
            }
        }
        return sValue;
    }
}

function GoBack(el)
{
    var sType = el.type;
    switch(sType)
    {
        case "text":
        case "hidden":
        case "password":
        case "file":
        case "textarea": el.focus();var rng = el.createTextRange(); rng.collapse(false); rng.select();
        case "checkbox":
        case "radio": var els = document.getElementsByName(el.name);els[0].focus();
        case "select-one":
        case "select-multiple":el.focus();
    }
}
function CheckField(Field)
{
        if(Field.check)
        {
            var sReg = Field.check;
            var sVal = GetValue(Field);
            var reg = new RegExp(sReg);
            if(!reg.test(sVal))
            {
                alert(Field.warning);
                GoBack(Field) ;
                return false;
            }
        }
  return true;   
}
